package cn.gok;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

/**
 * @Author: LKSV
 * @Description:
 * @Date:Created in 20:05 2021/8/22
 */
public class UserServerHandler extends ChannelInboundHandlerAdapter {
    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) {
        if (msg.toString().startsWith("UserService")) {

            //满足一定规则，则创建UserServiceImpl实例，并返回数据
            String result = new UserServiceImpl()
                    .sayHello(msg.toString().substring(
                            msg.toString().lastIndexOf("#") + 1));
            ctx.writeAndFlush(result);
        }
    }
}
